package com.glorystone.ins.task;

import com.glorystone.ins.service.IReceivableService;
import com.glorystone.ins.vo.ReceivableVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * @author:liuhongjie
 * @Date:Created in 10:59 2018/3/21
 * @since: JDK 1.7
 * @projectName:IntelliJ IDEA
 * @Description:类功能描述
 */
@Service
@Slf4j
@Lazy(false)
public class OrderTask {

    @Autowired
    private IReceivableService receivableService;

    /**
     * 每天零点执行跑批，订单表中垫资账期到期日小于当天的视为已逾期，修改应收渠道订单状态为已逾期状态
     */
    //@Scheduled(cron = "0 0 0 * * ?")
    @Scheduled(cron = "0 0/10 * * * ?")
    public void updateOverdueStatus(){
        ReceivableVO receivable = new ReceivableVO();
        receivable.setAccountMaturityDate(LocalDate.now());
        receivableService.updateOverdueStatus(receivable);
    }

}
